﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.DataVisualization.Charting;
using System.Web.UI.WebControls;

public partial class Charts_CentersUsage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        CentersUsageChart.Titles[0].Text = string.Format("نمودار مصرف انرژی {1} مراکز در تاریخ {0}", DatePersianDateTextBox.Text, TypeDropDownList.SelectedItem);
    }
    protected void ChartLinkButton_Click(object sender, EventArgs e)
    {
        CentersUsageSqlDataSource.DataBind();
        Series series = new Series();
        series.Name = "میزان مصرف";
        series.ChartType = SeriesChartType.StackedColumn;
        series.Color = Color.Blue;
       
        DataView dataView = new DataView();
        DataTable dataTable = new DataTable();
        dataView = CentersUsageSqlDataSource.Select(DataSourceSelectArguments.Empty) as DataView;
        if (dataView != null)
        {
            dataTable = dataView.ToTable();
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                series.Points.AddXY(dataTable.Rows[i].ItemArray[1], dataTable.Rows[i].ItemArray[0]);
            }
            CentersUsageChart.Series.Add(series);
            CentersUsageChart.DataBind();
        }
    }
}